import { reqlogin } from '../utils/index.js'
const user = {
	actions: {
		async login({commit}, value) {
			const res = await reqlogin(value)
			console.log('res2', res)
			if(res.error) {
				return Promise.reject(res.error)
			}
			uni.setStorage({
				key: 'userInfo',
				data: res
			})
			commit('LOGIN', res)
			return '登录成功'
		}
	},
	mutations: {
		LOGIN(state, info) {
			state.userInfo = info
		}
	},
	state: {
		userInfo: null
	}
}
export default user